import { defineConfig } from 'rollup'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import terser from '@rollup/plugin-terser'

export default defineConfig({
  input: 'index.js',
  external: [
    'vue',
    'element-plus'
  ],
  output: [
    {
      file: 'dist/index.js',
      format: 'cjs',
      exports: 'named'
    },
    {
      file: 'dist/index.esm.js',
      format: 'es'
    },
    {
      file: 'dist/index.umd.js',
      format: 'umd',
      name: 'VueCrudComposable',
      globals: {
        vue: 'Vue',
        'element-plus': 'ElementPlus'
      }
    },
    {
      file: 'dist/index.umd.min.js',
      format: 'umd',
      name: 'VueCrudComposable',
      plugins: [terser()],
      globals: {
        vue: 'Vue',
        'element-plus': 'ElementPlus'
      }
    }
  ],
  plugins: [
    resolve({
      preferBuiltins: false
    }),
    commonjs()
  ]
})